<template>
  <div>
    <div align="center">
      <label size="large" label-width="280px">— — — — — — — — — — — </label><br/>
      <label size="large" label-width="280px">* * * 电梯运行故障预警分析模型 * * *</label><br/>
      <label size="large" label-width="280px">— — — — — — — — — — — </label>
    </div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="300px">
      <el-form-item label="位置" prop="position">
        <el-input v-model="formData.position" placeholder="请输入位置" clearable :style="{width: '80%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="X轴三个方向上的重构误差" prop="xTmpList">
        <el-input v-model="formData.xTmpList" type="textarea"
                  placeholder="请输入X轴三个方向上的重构误差，同时输入多个同时输入多个，如：0.0009,0.0008,0.0010"
                  :autosize="{minRows: 4, maxRows: 4}" :style="{width: '80%'}"></el-input>
      </el-form-item>
      <el-form-item label="Y轴三个方向上的重构误差" prop="yTmpList">
        <el-input v-model="formData.yTmpList" type="textarea"
                  placeholder="请输入Y轴三个方向上的重构误差，集中在0.0060左右，同时输入多个，如：0.0060,0.0061,0.0062"
                  :autosize="{minRows: 4, maxRows: 4}" :style="{width: '80%'}"></el-input>
      </el-form-item>
      <el-form-item label="Z轴三个方向上的重构误差" prop="zTmpList">
        <el-input v-model="formData.zTmpList" type="textarea"
                  placeholder="请输入Z轴三个方向上的重构误差，集中在0.0012 左右，同时输入多个，如：0.0012,0.0011,0.0013"
                  :autosize="{minRows: 4, maxRows: 4}" :style="{width: '80%'}"></el-input>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
      title="评估结果"
      :visible.sync="centerDialogVisible"
      width="30%"
      center>
      <span>报警状态:（{{alarm}}）;---  报警类型:（{{direction}}）方向</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="centerDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {handlerDTYX22} from "../../../api/edu/risk";

  export default {
    components: {},
    props: [],
    data() {
      return {
        formData: {
          position: null,
          xTmpList: null,
          yTmpList: null,
          zTmpList: null,
          xList: [0.0009,0.0008,0.0010],
          yList: [0.0009,0.0008,0.0010],
          zList: [0.0009,0.0008,0.0010],
        },
        formData1: {
        position: "2233",
        xlist: [

      ],
        ylist: [

      ],
        zlist: [

      ]
        },
        rules: {
          position: [{
            required: true,
            message: '请输入位置',
            trigger: 'blur'
          }],
          xTmpList: [{
            required: true,
            message: '请输入X轴三个方向上的重构误差，同时输入多个同时输入多个，如：0.0009,0.0008,0.0010',
            trigger: 'blur'
          }],
          yTmpList: [{
            required: true,
            message: '请输入Y轴三个方向上的重构误差，集中在0.0060左右，同时输入多个，如：0.0060,0.0061,0.0062',
            trigger: 'blur'
          }],
          zTmpList: [{
            required: true,
            message: '请输入Z轴三个方向上的重构误差，集中在0.0012 左右，同时输入多个，如：0.0012,0.0011,0.0013',
            trigger: 'blur'
          }],
        },
        centerDialogVisible : false,
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      submitForm() {
        this.formData1.xlist = this.formData.xTmpList.split(',')
        this.formData1.ylist = this.formData.yTmpList.split(',')
        this.formData1.zlist = this.formData.zTmpList.split(',')
        debugger
        handlerDTYX22(this.formData1).then(response => {
          console.log(response)
          if(response.X){
            this.direction = 'X';
          }
          else if(response.Y){
            this.direction =  'Y';
          }
          else if(response.Z){
            this.direction =  'Z';
          }
          if(response.alarm==='YES')
          {
            this.alarm = '是';
          }
          else {
            this.alarm = '否';
          }
          this.centerDialogVisible = true
        }).catch((error) => {
          console.log(error);
        });
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
    }
  }

</script>
<style>
</style>
